package com.bangdream.michelia.view.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bangdream.michelia.R;

/**
 * @date on 2018/6/18 16:29
 * @email 909732184@qq.com
 * 我的学习记录适配器
 */
public class MyLearningRecordsAdapter extends RecyclerView.Adapter {
    private Context context;
    private LayoutInflater layoutInflater;
    private OnItemClickListener onItemClickListener;

    public OnItemClickListener getOnItemClickListener() {
        return onItemClickListener;
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public interface OnItemClickListener{
        void onExaminationItemClick(int position);
    }
    public MyLearningRecordsAdapter(Context context) {
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(layoutInflater.inflate(R.layout.learning_records_adapter_item,parent,false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder viewHolder = null;
        if(holder instanceof ViewHolder){
            viewHolder = (ViewHolder) holder;
            viewHolder.position = position;

        }
    }

    @Override
    public int getItemCount() {
        return 20;
    }
    class ViewHolder extends RecyclerView.ViewHolder{
        private int position;
        private TextView tvGoExamination;
        public ViewHolder(View itemView) {
            super(itemView);
            tvGoExamination = itemView.findViewById(R.id.tvGoExamination);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if(onItemClickListener!=null){
                        onItemClickListener.onExaminationItemClick(position);
                    }
                }
            });
        }
    }
}
